package com.umf.b2b.demo;

import com.umpay.dto.UMFResponse.Message;
import com.umpay.mer.ConfigContext;
import com.umpay.util.CipherUtil;
import com.umpay.util.UMFUtil;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: PostDemo  
 * @Description: POST请求demo
 */
public class PostDemoOld {
	    
	    static ConfigContext apiContext;
	    static String merDate = new SimpleDateFormat("yyyyMMdd").format(new Date());
	    //商户接入请求地址
	    static String url = "http://b2b.umfintech.com/merAccess";
	    static {
	        apiContext = new ConfigContext(url, "90000002");
	    }
	    
	    public static void main(String[] args) throws Exception {
	    	personRegister(); //post请求以用户注册为例
	    }
	    static void personRegister() throws Exception {
	    	//组装请求数据
	        Map<String, Object> reqMap = new HashMap<String, Object>();
	        reqMap.put("mer_id", "90000002");
	        reqMap.put("version", "1.0");
	        reqMap.put("order_id", String.valueOf(new Date().getTime()));
	        reqMap.put("mer_date", merDate);
	        reqMap.put("mer_cust_id",String.valueOf(new Date().getTime())) ;
	        reqMap.put("user_type", "1"); //个人用户
	        reqMap.put("cust_name", CipherUtil.encrypt("姓名"));
	        reqMap.put("identity_type", "1"); //身份证
	        reqMap.put("identity_code", CipherUtil.encrypt(""));  //身份证号
	        reqMap.put("mobile_id", "15201044482"); //手机号
	        reqMap.put("notify_url", "http://商户接收后台通知的地址");
	        apiContext.setUrl(url + "/register/personal");
	        try {
	           System.out.println("商户接入请求参数："+reqMap);
	           Message<Map> retMessage = UMFUtil.post(apiContext, reqMap, Map.class);
	           System.out.println("商户接入响应结果："+retMessage);
	        } catch (Exception e) {
	            e.printStackTrace();
	        }
	    }
}

